home *** CD-ROM | disk | FTP | other *** search
- /*
-
- WATCH v1.4
-
- Programed by Keijiro Takahashi (novice)
-
- */
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <winb.h>
- #include <te.h>
- #include <fntb.h>
- #include <gui.h>
- #include <egb.h>
- #include <guidbg.h>
- #include <eintm.h>
- #include <dlib.h>
-
- #define rsmId "%%% DWATCHv1.4 %%%"
-
-
- extern void initIcn();
- extern void idleTask();
- int APL_init();
- int loadRsm();
-
- extern MMIINIT initDataBASE ;
- extern int h12Sw;
- char *guiEgbPtr ;
- int rsmx,rsmy,rsmSw;
-
-
-
-
-
- /*
-
- Main
-
- */
- void main()
- {
- if(APL_init()==NOERR)
- {
- idleTask();
- MMI_ExecSystem();
- }
- ICNTerm();
- MMI_Close();
- }
-
-
-
-
- /*
-
- Initialize
-
- */
- int APL_init()
- {
-
- int ret ;
- MMICTRL mmi;
-
- mmi.page0=SCREEN16 | SCREENIGNORE;
- mmi.page1=SCREENUNUSED;
- mmi.writePage=0;
- mmi.displayPage=SCREENAVAILABLE;
- mmi.priority=0;
- mmi.mode=SCREENAVAILABLE;
- mmi.width=SCREENEXPAND;
- mmi.move.lupx=-16384;
- mmi.move.lupy=-16384;
- mmi.move.rdwx=16383;
- mmi.move.rdwy=16383;
- mmi.white=15;
- mmi.black=8;
- mmi.gray=7;
- mmi.xor=7;
- mmi.size=0;
- mmi.ptr=NULL;
- mmi.asize=0;
- mmi.aptr=NULL;
-
- if ((ret = MMI_Open(&mmi)) != NOERR) return ret ;
-
- if ((ret = MMI_initHyper()) < 0) return ret ;
- if ((ret = MMI_initDialogL40()) < 0) return ret ;
- if ((ret = MMI_initWindowL40()) < 0) return ret ;
- if ((ret = MMI_initMessageL40()) < 0) return ret ;
- if ((ret = MMI_initButtonL40()) < 0) return ret ;
- if ((ret = MMI_initDrawButtonL40()) < 0) return ret ;
- if ((ret = MMI_initIconL40()) < 0) return ret ;
-
- if ((ret = MMI_Init(&initDataBASE)) < 0) return ret ;
-
- guiEgbPtr = MMI_GetEgbPtr();
- EIN_initGuiColor();
-
- if ((ret = ICNInit(0)) != 0) return ret;
- initIcn();
-
-
- extern int shell();
- MMI_SendMessage(MMI_GetBaseObj(),MM_SETEXEC,1,shell);
- MMI_CallMessage(MMI_GetApliId(),GM_TITLE,
- (int)"WATCH v1.3 By Keijiro",0);
-
- MMI_SetIdleTaskFunc(idleTask);
-
-
- extern int baseWin;
-
- if (loadRsm())
- {
- MMI_SendMessage(baseWin,MM_MOVE,2,rsmx,rsmy);
- }
- else
- {
- WINCTRL *pctrl;
- MMI_GetControl(&pctrl);
- MMI_SendMessage(baseWin,MM_MOVE,2,
- (pctrl->bound.rdwx-138)/2,(pctrl->bound.rdwy-101)/2);
- }
-
-
- MMI_SendMessage(MMI_GetBaseObj(),MM_SHOW,0);
-
- return NOERR ;
- }
-
-
-
-
-
-
- int loadRsm()
- {
- char work[RSMWORKSIZE],buf[1024];
- char *ptr;
- int size;
-
- EIN_rsmInit(work,rsmId);
- EIN_rsmBufSet(work,buf,1023);
-
- size = EIN_rsmLoad(work);
-
- if (size>0)
- {
- if ( (ptr=strstr(buf,"\nSWITCH: ")) != NULL )
- {
- if (sscanf(ptr,"\nSWITCH: %d\n",&h12Sw) > 0)
- {
- rsmSw=h12Sw;
- }
- }
-
- if ( (ptr=strstr(buf,"\nMAINPOS: ")) != NULL )
- {
- if (sscanf(ptr,"\nMAINPOS: %d %d\n",&rsmx,&rsmy) > 1)
- {
- return(1);
- }
- }
- }
-
- return(0);
- }
-
-
-
-
-
-
- void saveRsm()
- {
- extern int baseWin;
- HYPER hyp;
-
- MMI_SendMessage(baseWin,MM_GETHYPER,1,&hyp);
-
- if ( (rsmx!=hyp.fr.lupx) || (rsmy!=hyp.fr.lupy) || (rsmSw!=h12Sw) )
- {
- char work[RSMWORKSIZE],buf[1024];
- char aplpath[128];
-
- EIN_rsmInit(work,rsmId);
- EIN_rsmBufSet(work,buf,1023);
-
- MMI_CallMessage(MMI_GetApliId(),GM_QUERYID,QM_PATH,(int)aplpath );
-
- EIN_rsmBufPrintf(work,"APLPATH: %s",aplpath);
- EIN_rsmBufCat (work,"TITLE: WATCH v1.4");
- EIN_rsmBufCat (work,"COMMENT: スタンダードな時計");
- EIN_rsmBufPrintf(work,"SWITCH: %d",h12Sw);
- EIN_rsmBufPrintf(work,"MAINPOS: %d %d",hyp.fr.lupx,hyp.fr.lupy);
- EIN_rsmBufTail(work);
- EIN_rsmSave(work);
- }
-
- return;
- }
-